/*******************************************************************************
* Project: QSAR(Cute Software Architecture)
*
* Copyright: Copyright(C) 2024 by YuetingBen, All Rights Reserved
*
* File name: EcuMType.h
*
* Brief: ;
*
* Author: Yueting.Ben
*
* Module: EcuM
*
*******************************************************************************/

#ifndef ECUMTYPE_H
#define ECUMTYPE_H

/** HEADER FILES **/
#include "PlatformCfg.h" 


/** MACRO DEFINITION **/


/** TYPEDEF DEFINITION **/
typedef uint32 EcuM_WakeupSourceType;
/* Power cycle (bit 0) */
#define ECUM_WKSOURCE_POWER ((EcuM_WakeupSourceType)0x01)
/* Hardware reset (bit 1). If the Mcu driver cannot distinguish between a power cycle and a reset reason, then this shall
be the default wakeup source */
#define ECUM_WKSOURCE_RESET ((EcuM_WakeupSourceType)0x02)
/* Internal reset of uC (bit 2) The internal reset typically only resets the C core but not
peripherals or memory controllers. The exact behavior is hardware specific. This source may also
indicate an unhandled exception. */
#define ECUM_WKSOURCE_INTERNAL_RESET ((EcuM_WakeupSourceType)0x04)
/* Reset by internal watchdog (bit 3) */
#define ECUM_WKSOURCE_INTERNAL_WDG ((EcuM_WakeupSourceType)0x08)
/* Reset by external watchdog (bit4), if detection supported by hardware */
#define ECUM_WKSOURCE_EXTERNAL_WDG ((EcuM_WakeupSourceType)0x10)

/* Thetypedescribesthepossiblestatesofawakeupsource */
typedef uint8 EcuM_WakeupStatusType;
/* Nopendingwakeupeventwas detected */
#define ECUM_WKSTATUS_NONE ((EcuM_WakeupStatusType)0u)
/* Thewakeupeventwasdetected butnotyetvalidated */
#define ECUM_WKSTATUS_PENDING ((EcuM_WakeupStatusType)1u)
/* Thewakeupevent isvalid */
#define ECUM_WKSTATUS_VALIDATED ((EcuM_WakeupStatusType)2u)
/* Thewakeupeventhasnotbeen validatedandhasexpired therefore */
#define ECUM_WKSTATUS_EXPIRED ((EcuM_WakeupStatusType)3u)

/* This type describes the reset mechanisms supported by the ECU State Manager. It can be extended by configuration */
typedef uint8 EcuM_ResetType;
#define ECUM_RESET_MCU ((EcuM_ResetType)0u) /* Microcontroller reset via Mcu_PerformReset */
#define ECUM_RESET_WDG ((EcuM_ResetType)1u) /*Watchdog reset via WdgM_PerformReset */
#define ECUM_RESET_IO ((EcuM_ResetType)2u) /* Reset by toggeling an I/O line */

/* ECUState Manager states */
typedef uint8 EcuM_StateType;
#define ECUM_SUBSTATE_MASK ((EcuM_StateType)0x0f)
#define  ECUM_STATE_STARTUP ((EcuM_StateType)0x10)
#define ECUM_STATE_RUN ((EcuM_StateType)0x32)
#define ECUM_STATE_POST_RUN ((EcuM_StateType)0x33)
#define ECUM_STATE_SHUTDOWN ((EcuM_StateType)0x40)
#define ECUM_STATE_SLEEP ((EcuM_StateType)0x50)

typedef uint8 EcuM_UserType; /* Unique value for each user */

typedef uint32 EcuM_TimeType; /* This data type represents the time of the ECU Manager module */

/* This type represents the boot targets the ECU Manager module can be configured with. The
default boot target is ECUM_BOOT_TARGET_OEM_BOOTLOADER. */
typedef uint8 EcuM_BootTargetType;
#define ECUM_BOOT_TARGET_APP ((EcuM_BootTargetType)0u) /* The ECU will boot into the application */
#define ECUM_BOOT_TARGET_OEM_BOOTLOADER ((EcuM_BootTargetType)1u) /* The ECU will boot into the OEM bootloader */
#define ECUM_BOOT_TARGET_SYS_BOOTLOADER ((EcuM_BootTargetType)2u) /* The ECU will boot into the system supplier bootloader */

/* This type describes the cause for a shutdown by the ECU State Manager. It can be extended by configuration */
typedef uint8 EcuM_ShutdownCauseType;
#define ECUM_CAUSE_UNKNOWN ((EcuM_ShutdownCauseType)0u) /* No cause was set. */
#define ECUM_CAUSE_ECU_STATE ((EcuM_ShutdownCauseType)1u) /* ECU state machine entered a state for shutdown */
#define ECUM_CAUSE_WDGM ((EcuM_ShutdownCauseType)2u) /* Watchdog Manager detected a failure */
#define ECUM_CAUSE_DCM ((EcuM_ShutdownCauseType)3u) /* Diagnostic Communication Manager requests a shutdown due to a service request */

/* This data type represents the modes of the ECU Manager module */
typedef uint16 EcuM_ShutdownModeType;

typedef uint8 EcuM_ShutdownTargetType;
#define ECUM_SHUTDOWN_TARGET_SLEEP ((EcuM_ShutdownTargetType)0x00)
#define ECUM_SHUTDOWN_TARGET_RESET ((EcuM_ShutdownTargetType)0x01)
#define ECUM_SHUTDOWN_TARGET_OFF ((EcuM_ShutdownTargetType)0x02)


#endif

